﻿<%@ Page Title="" Language="C#" MasterPageFile="~/web/common/admin_common.Master" AutoEventWireup="true" CodeBehind="List.aspx.cs" Inherits="shop.web.view_admin.user.List" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>用户列表</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <form class="layui-form" action="List.aspx">
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">用户等级</label>
            <div class="layui-inline">
                <select lay-verify="required" name="rankId">
                    <option>用户等级</option>
                    <%foreach (var role in roleList)
                        {
                    %>
                    <option value="<%=role.Id %> "><%=role.RoleName %></option>
                    <%
                        } %>
                </select>
            </div>
           <div class="layui-inline">
                <input type="submit" value="查找" class="layui-btn" />
            </div>
          <div class="layui-inline">
                <a class="layui-btn" href="Add.aspx">添加</a>
            </div>

        </div>
         

    </form>

    <table class="layui-table" lay-skin="row line">
        <tr class="tr1">
            <td>编号</td>
            <td>姓名</td>
            <td>密码</td>
            <td>等级</td>
            <td>注册时间</td>
            <td colspan="2">操作</td>
        </tr>
        <%foreach (var user in userList)
            { %>
        <tr class="tr2">
            <td><%=user.Id %></td>
            <td><%=user.Name %></td>
            <td><%=user.Password%></td>
            <td><%=user.Rank %></td>
            <td><%=user.Register_time%></td>

            <%--<td><a href="/web/view_admin/user/edit.aspx?id=<%#Eval("Id") %>" class="layui-btn  layui-btn-xs">查看</a></td>--%>
            <td><a href="/web/view_admin/user/edit.aspx?id=<%=user.Id %>" class="layui-btn  layui-btn-xs">编辑</a></td>
            <td><a href="javascript:deleteUser( <%=user.Id %> )" class="layui-btn layui-btn-danger layui-btn-xs">删除</a></td>
        </tr>
        <%} %>
    </table>
    <script>
        function deleteUser(id) {
            var index = layer.confirm('确定删除该商品？', function (index) {
                $.post("/handler/UserHandler.ashx?method=delete&id=" + id, function (data) {
                    var obj = JSON.parse(data);
                    console.log(data)
                    if (obj.ErrorCode === 0) {
                        //成功
                        layer.msg(obj.Message, { icon: 6 ,time : 2000}, function () {
                             window.location.reload();
                        });                      
                    } else {
                        layer.msg(obj.Message, { icon: 2 })
                    }
                })

                layer.close(index);
            });

        }
    </script>
</asp:Content>

